package main

import (
	"context"
	"fmt"
	"os"
	"time"

	"gitee.com/dongzi1998/openrouter-go"
	"github.com/joho/godotenv"
)

func main() {

	loadEnvErr := godotenv.Load(".env")
	if loadEnvErr != nil {
		panic(loadEnvErr)
	}

	client := openrouter.NewClient(
		os.Getenv("OPENROUTER_API_KEY"),
		openrouter.WithXTitle("openrouter-go-example3"),
		openrouter.WithTimeout(20*time.Second),
	)

	resp, err := client.CreateChatCompletion(context.Background(), openrouter.ChatCompletionRequest{
		Model: "mistralai/mistral-medium-3.1",
		Messages: []openrouter.ChatCompletionMessage{
			{
				Role:    "user",
				Content: "Hello!",
			},
		},
	})

	if err != nil {
		panic(err)
	}

	fmt.Println(resp.Choices[0])
}
